<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="认领列表" libs=["table"]/>
<div class="container-div" id="_app">
    <div class="row">
        <div class="col-sm-12 search-collapse">

            <!--我们在body中加入一个div，里面放入一个table-->
            <div style="display:none" id="test">
                <h4>高级查询</h4>
                <hr>
                <table class="table table-striped">
                    <tbody>
                    <tr>
                        <td><@ctx.i18n text = "检验编号"/>：</td>
                        <td><input type="text" class="form-control" name="testingProject2"  placeholder="请输入检测项目"></td>
                        <td><@ctx.i18n text = "样品类型"/>：</td>
                        <td><input type="text" class="form-control" name="chargeUnit2"  placeholder="请输入计价单位"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "执行标准"/>：</td>
                        <td><input type="text" class="form-control" name="price"  placeholder="请输入定价"></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="select-time" colspan="4"><label>登记时间：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="beginTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect" style="width: 150px" ><label>--</label><input type="text" name="endTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect2" style="width: 150px"></td>
                    </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="2" align="center"><a class="btn btn-primary btn-rounded btn-sm" id="search" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a></td>
                        <td colspan="2" align="center"><a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a></td>
                    </tr>
                    </tfoot>
                </table>
            </div>

            <@f.form id="module-form">
            <div class="select-list">
                <ul>
                    <li >
                        <label>检验编号： </label>
                        <@f.input id="sampleCode" name="testCode"/>
                    </li>
                    <li>
                        <@ctx.i18n text = "样品类型"/>：
                        <input type="text" class="form-control" name="testType"/>
                    </li>

                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a>
                    </li>
                </ul>
            </div>
        </@f.form>
    </div>
    <@table id="bootstrap-table">
    <@shiro.hasPermission name="pms:entry:add">
    <a class="btn btn-success" onclick="opt.operate.add(0)">
        <i class="fa fa-plus"></i> <@ctx.i18n text = "新增"/>
    </a>
    </@shiro.hasPermission>
    <@shiro.hasPermission name="pms:entry:edit">
    <a class="btn btn-primary multiple disabled" onclick="opt.operate.edit()">
        <i class="fa fa-edit"></i> <@ctx.i18n text = "修改"/>
    </a>
    </@shiro.hasPermission>
    <@shiro.hasPermission name="pms:entry:del">
    <a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
        <i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/>
    </a>
    </@shiro.hasPermission>
    <@shiro.hasPermission name="pms:entry:export">
    <a class="btn btn-warning" onclick="$.table.exportExcel()">
        <i class="fa fa-download"></i> 导出
    </a>

    </@shiro.hasPermission>
<!--onclick="upload()"-->
    <a class="btn btn-info"  id="licSelect">
        <i class="fa fa-upload"></i> 导入
        <!--<input   id="files"  type="file" />-->
        <!--<input type="file" id="files" value="" style="display:none">-->
    </a>



</@table>
</div>
</div>
<@footer>
<script type="text/javascript">
    // var statusDatas = ${dict.getDictListJson('claim_status')};
    var editFlag = "${permission.hasPermi("pms:entry:edit")}";
    var listFlag = "${permission.hasPermi("pms:entry:add")}";
    // var categoryDatas = ${dict.getDictListJson('sys_bpm_category')};
    var prefix = baseURL + "pms/entry";

    $(function() {
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: true,
            sortName: "id",
            delUrl: prefix + "/del",
            addUrl: prefix + "/add",
            editUrl: prefix + "/edit/{id}",//认领箱
            exportUrl: prefix + "/export",
            importUrl: prefix + "/import",
            uniqueId: 'id' , /* 唯一ID */
            modalName: "检测数据录入",
            columns: [
                // {field: 'selectItem', radio: true},
                {title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                        return $.table.serialNumber(index);}},
                // {field : 'id',title : '<@ctx.i18n text = "编号"/>'},
                {field : 'testCode',title : '<@ctx.i18n text = "检验编号"/>'},
                {field : 'entrustCode',title : '<@ctx.i18n text = "委托编号"/>'},
                {field : 'executiveStandard',title : '<@ctx.i18n text = "执行标准"/>'},
                {field : 'registrationTime',title : '<@ctx.i18n text = "登记日期"/>'},


                //     {field : 'id',title : ''},

                {title:"<@ctx.i18n text = "操作"/>",align: 'left',class:'action',formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "关联流程表单"/>" onclick="taskFrom(\'' + row.id + '\')"><i class="fa icon-organization"></i></a> ');
                //        actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "认领修改"/>" onclick="taskFromEdit(\'' + row.id + '\')">认领修改</a> ');
                        actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "数据录入"/>" onclick="dataEntry(\'' + row.id + '\')">数据录入</a> ');
                        actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "编辑原始数据"/>" onclick="editData(\'' + row.id + '\')">编辑原始数据</a> ');

                        return actions.join('');
                }}
            ]
        };
        $.table.init(options);
    });

    function dataEntry(id){
        opt.modal.openTab("数据录入",prefix + "/dataEntry/"+id);
        // opt.operate.post(prefix + "/taskAdd", { "id": id});
        // opt.modal.confirm("确认出库吗?", function() {
        //     opt.operate.post(prefix + "/checkout", { "id": id});
        // })
    }

    function editData(id){
        opt.modal.openTab("数据录入",prefix + "/editData/"+id);

    }

    /* 用户管理-重置密码 */
    function upload() {
        var options = {
            title: "选择文件",
            width: "800",
            height: "300",
            url: prefix + '/selectFile',
            callBack: DeptDoSubmit
        };
        opt.modal.openOptions(options);
    }

    function DeptDoSubmit(index, layero) {

        var body = layer.getChildFrame('body', index);
        console.log(body);
        importTable(body.find('#fileName').val());
        layer.close(index);
    }



    function taskFromEdit(id) {
        // opt.modal.confirm("确认要删除流程定义吗?", function() {
        //  opt.modal.openTab(prefix + "/edit", { "id": id});
        console.log("1111111111");
        console.log(id);
        console.log("11111111");
        opt.modal.openTab("认领修改",prefix + "/edit/"+id);
        // })
    }

    function taskFrom(id){


        opt.modal.openTab("关联表单",prefix + "/taskfrom/"+id);
    }


    $('#licSelect').click(function(){
        opt.layer.open({
            type: 1,
            area: ['580px', '180px'],
            title: '<i class="fa fa-upload"></i> 导入文件 <i class="fa fa-info-circle" style="color: red"></i>!',
            shade: 0.3,
            shadeClose: true,
            resize: false,
            scrollbar: true,
            content: opt.template('upload'),
            btn: ['<i class="fa fa-check"></i> 上传',
                '<i class="fa fa-remove"></i> 取消'],
            btn1: function(index, layero){
                var form = {
                    inputForm: layero.find('#inputForm'),
                    f: layero.find('#f').val()
                };
                if (form.f == '' || !opt.common.endWith(form.f, '.xlsx'||!opt.common.endWith(form.f, '.xls'))){
                    opt.warning("<@ctx.i18n text = "文件不正确，请选择后缀为 . xls和xlsx的文件。"/>");
                    return false;
                }
                var formdata = new FormData();
                var file = layero.find('#f')[0].files[0];
                formdata.append("files", file);
                opt.common.sendAjax({
                    url: prefix + "/upload",
                    data: formdata,
                    type: "POST",
                    processData: false,
                    contentType: false,
                    success: function(result) {
                        if(result.code == opt.variable.web_status.SUCCESS){
                            opt.layer.closeAll();
                            opt.success("<@ctx.i18n text = "文件上传成功!"/>");
                            location.reload();
                        }else{
                            opt.error(result.msg);
                        }
                    }
                });
                return true;
            }
        });
    });
</script>

</@footer>
</@pageTheme>